// StatusEnum.java
package com.health.common.enums;

public enum ProductStatusEnum {
    ON_SHELF("0", "已上架"),
    OFF_SHELF("1", "未上架"),
    PENDING_REVIEW("2", "待审核"),
    REJECTED("3", "未通过");

    private final String code;
    private final String desc;

    ProductStatusEnum(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public String getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    public static ProductStatusEnum getByCode(String code) {
        for (ProductStatusEnum status : values()) {
            if (status.getCode().equals(code)) {
                return status;
            }
        }
        return null;
    }

    public static String getDescByCode(String code) {
        ProductStatusEnum status = getByCode(code);
        return status != null ? status.getDesc() : "";
    }
}